package com.func.domain.credit.model.entity;

import com.func.domain.award.model.valobj.TaskStateVO;
import com.func.domain.credit.event.CreditAdjustSuccessMessageEvent;
import com.func.domain.credit.model.valobj.TradeNameVO;
import com.func.domain.credit.model.valobj.TradeTypeVO;
import com.func.types.event.BaseEvent;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * <p>
 * TradeEntity
 * </p>
 *
 * @author Simon
 * @version 2025.03.23.1.0.0
 * @description 增加额度实体
 * @since 2025-03-23
 */

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TradeEntity {
    // 用户ID
    private String userId;
    // 交易名称
    private TradeNameVO tradeName;
    // 交易类型
    private TradeTypeVO tradeType;
    // 交易金额
    private BigDecimal amount;
    // 业务防重ID - 外部透传, 唯一标识
    private String outBusinessNo;

    public static TaskEntity createTaskEntity(String userId, String topic, String messageId, BaseEvent.EventMessage<CreditAdjustSuccessMessageEvent.CreditAdjustSuccessMessage> message) {
        TaskEntity taskEntity = new TaskEntity();
        taskEntity.setUserId(userId);
        taskEntity.setTopic(topic);
        taskEntity.setMessageId(messageId);
        taskEntity.setMessage(message);
        taskEntity.setState(TaskStateVO.create);
        return taskEntity;
    }
}
